package com.tanhua.backmanage.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.tanhua.backmanage.mapper.ManagerInfoMapper;
import com.tanhua.backmanage.pojo.Manager;

import com.tanhua.backmanage.utils.ManagerThreadLocal;
import com.tanhua.backmanage.vo.ManagerInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ManagerInfoService {
    @Autowired
    private ManagerInfoMapper managerInfoMapper;


    public ManagerInfo selectManagerInfo() {
        //无需校验,直接获取
        Manager manager = ManagerThreadLocal.get();
        if (null == manager) {
            //token非法或已经过期
            return null;
        }
        Long uid = manager.getId();
        QueryWrapper<ManagerInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("uid", uid);
        ManagerInfo managerInfo = this.managerInfoMapper.selectOne(queryWrapper);
        return managerInfo;
    }

}
